#include "PhysicEngine.hpp"


PhysicEngine::PhysicEngine():
m_world(NULL)
{
}
PhysicEngine::~PhysicEngine()
{
	destroyWorld();
}

PhysicEngine::PhysicEngine(const PhysicEngine& pe):
m_world(pe.m_world)
{

}
PhysicEngine& PhysicEngine::operator=(const PhysicEngine& pe)
{
	m_world = pe.m_world;
	
	return *this;
}
		
PhysicEngine& PhysicEngine::instance()
{
	static PhysicEngine pe;
	return pe;
}
		
b2World* PhysicEngine::world()
{
	if(m_world == NULL)
		createWorld();
	return m_world;
}

void PhysicEngine::createWorld()
{
	destroyWorld();
	m_world = new b2World(b2Vec2(),true); // no gravity
}

void PhysicEngine::destroyWorld()
{
	if(m_world != NULL)
	{
		delete m_world;
		m_world = NULL;
	}
}


